<?php 

Class msgModel extends AppModel
{
	
	public function get_msg_list($page=1)
	{
	
		$listPage=array('data'=>'','pageLink'=>'');
		
		$result=$this->show_page("SELECT id,name,phone,email ,content,created FROM ".$this->table('feed'),$page);
		$listPage['pagelink']=$result['page'];
		foreach($result['result'] as $k=>$v)
		{
			if(hy_strlen($v['content'])>6)
			{
			  $result['result'][$k]['content']=hy_substr(trim($v['content']),6).'...';
			}
		}
		
		$listPage['data']=$result['result'];
		
		
		return $listPage;
	
	}
	public function get_msg_info($id)
	{
		
	    if($id)
		{
		  $sql="SELECT * FROM ".$this->table('feed')." WHERE id = '".$id."'";
			
		  $result=$this->getRow($sql);
		  if($result)
		  {
		  	$result['name']=htmlentities($result['name']);
		  	$result['content']=htmlspecialchars($result['content']);
		  	$result['email']=htmlentities($result['email']);
			return $result;
		  }
		  else
		  {
			return $result=array();
		  }
		}
		
		
	}
	public function del_msg($id)
	{
		$result=array('error'=>0,'content'=>'');
		if($id)
		{
			
				$sql="DELETE FROM ".$this->table('feed')." WHERE  id='".$id."'";
	
				$res=$this->query($sql);
				 
				if(!$res)
				{
					$result['error']=1;
					$result['content']='删除失败';
				}
	
	
		}
			 return $result;
	}
}